<template>
  <div class="container"
       style="background-color:#fff;">
    <div class="details-page">
      <div class="bor-b"
           style="text-align: center;">
        <div class="title"><b>{{dynamic.title}}</b></div>
      </div>
      <div class="content"
           style="margin-top: 10px; margin-bottom: 20px;">时间&nbsp;:&nbsp;{{dynamic.updateTime}}</div>
      <p class="rule-text"
         v-html="dynamic.content"
         style="max-height: fit-content;"></p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dynamic: {},
    };
  },
  mounted: function () {
    this.initDynamic();
    //$("#goble_menu_div").hide();
    // this.initHeight();
  },
  methods: {
    initDynamic() {
      var _self = this;
      var body = {};
      body.params = { id: _self.$route.params.id };
      var url = _self.utilHelper.apiUrl + "/api/getPremisesDynamicDetail";
      this.$http.post(url, body).then(
        (response) => {
          var data = response.body;
          _self.dynamic = data.resData.premisesDynamic;
          _self.dynamic.content = this.imgTagAddStyle(_self.dynamic.content);
        },
        (response) => {
          console.log(response);
        }
      );
    },
    imgTagAddStyle(htmlstr) {
      var regex1 = new RegExp(
        "(i?)(<img)(?!(.*?style=['\"](.*)['\"])[^>]+>)",
        "gmi"
      );
      htmlstr = htmlstr.replace(regex1, '$2 style=""$3');
      var regex2 = new RegExp("(i?)(<img.*?style=['\"])([^>]+>)", "gmi");
      htmlstr = htmlstr.replace(regex2, "$2width:100%;height:auto;$3");
      return htmlstr;
    },
  },
};
</script>

<style scoped>
.rule-text .intro {
  width: auto !important;
}
.details-page .title {
  height: auto;
  white-space: normal;
  padding: 10px 0;
  line-height: 22px;
  font-weight: bold;
  font-size: 14px;
  text-align: left;
}
</style>